package com.jinzhi.api.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.annotation.Generated;

/**
 * swagger
 *
 * @author JIngChangTian
 * @since 2023-07-10
 */
@Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2023-06-17T10:55:33.686Z")
@Controller
@EnableSwagger2
@EnableSwaggerBootstrapUI
@Configuration
@Profile({"dev","test"})
public class SwaggerConfig {

    @RequestMapping(value = "/")
    public String index() {
        return "redirect:doc.html";
    }

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("家政后端管理")
                .description("家政后端管理接口文档")
                .version("1.0")
                .license("Apache 2.0")
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
                .build();
    }

    @Bean
    public Docket customImplementation() {
        return new Docket(DocumentationType.SWAGGER_2)
        		.groupName("家政后端管理")
                .select()
                //.apis(RequestHandlerSelectors.basePackage("com.jinzhi.sys.controller"))
                .apis(RequestHandlerSelectors.basePackage("com.jinzhi.api.controller.aunt"))
                .build()
                /*.directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
                .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)*/
                .apiInfo(apiInfo());
    }
}
